(function(e) {

	mui.plusReady(function() {
		plus.navigator.setStatusBarBackground('#3085D0');
		PanDianMain();
	});

})(mui);

function PanDianMain() {
	$("#itemList").html('');
	var jsonData = {
		"op": "Phone_GetStore_PanDian_Main"
	}

	var opts = {
		url: "",
		addressUrl: "testline",
		requestType: "POST",
		pastDate: jsonData
	};

	console.log(JSON.stringify(opts));

	plus.nativeUI.showWaiting();
	crossDomainAjax(opts, function(data) {
		console.log(JSON.stringify(data));
		plus.nativeUI.closeWaiting();
		if(!isEmpty(data)) {
			for(var i = 0; i < data.length; i++) {
				createItem(data[i]);
			}
		} else {
			$('.mui-content').html(
				'<div class="empty-list">暂无盘点计划</div>'
			);
		}

		$("#itemList li").on('tap', function() {
			var itemId = this.id;
			
			console.log('itemID:'+itemId);

			var postData = {
				pageflag: "scaninfo.html",
				itemId: itemId
			}
			console.log(JSON.stringify(itemId));
			var pageChange1 = {
				pageUrl: "inventory.html",
				createNew: true,
				postData: postData,
				aniShow: "fade-in"
			}
			pageChange(pageChange1);
		});
	}, function(s) {

	});
}

function createItem(item) {
	var createLi = document.createElement("li");
	createLi.id = item.JobCode;
	createLi.innerHTML = '<span>盘点单号：</span><em>' + item.JobCode + '</em><br />' +
		'<span>仓库：</span><em>' + item.StoreName + '</em><br />';
	$("#itemList").append(createLi);
}